package com.gc.baselib.img;

import android.widget.ImageView;

import androidx.annotation.DrawableRes;
import androidx.annotation.NonNull;

import com.bumptech.glide.load.DecodeFormat;
import com.bumptech.glide.load.Transformation;
import com.bumptech.glide.load.engine.DiskCacheStrategy;

/**
 * Created by zk on 2020/6/20.
 */

public class ImageLoadConfig {
    ImageView intoImageView;
    Object url;
    Object context;
    int radius;//圆角
    int width;//宽度
    int height;//高度
    float thumbnail;//大小 0-1之间


    @DrawableRes int placeholder;//占位图
    @DrawableRes int errorholder;//占位图
    private DiskCacheStrategy diskCacheStrategy = DiskCacheStrategy.AUTOMATIC;
     boolean isSkipCache;
    int fileType=FileType.Bitmap;//
    DecodeFormat format=DecodeFormat.DEFAULT;
    Transformation tranformation;
    private String errorUrl;
     IImageLoaderListener loaderListener;
    ImageView.ScaleType scaleType=ImageView.ScaleType.CENTER_CROP;


    public ImageLoadConfig(Object context, ImageView intoImageView, Object url){
        this.context=context;
        this.intoImageView=intoImageView;
        this.url=url;
    }
    ImageLoadConfig(){

    }
    public ImageLoadConfig imageview(ImageView intoImageView) {
        this.intoImageView = intoImageView;
        return this;
    }
    public ImageLoadConfig scaleType(ImageView.ScaleType scaleType) {
        this.scaleType = scaleType;
        return this;
    }

    public ImageLoadConfig url(Object url) {
        this.url = url;
        return this;
    }
    public ImageLoadConfig tranformation(Transformation tranformation) {
        this.tranformation = tranformation;
        return this;
    }

    public ImageLoadConfig context(Object context) {
        this.context = context;
        return this;
    }

    public ImageLoadConfig radius(int radius) {
        this.radius=radius;
        return this;
    }

    public ImageLoadConfig size(int width, int height) {
        this.width=width;
        this.height=height;
        return this;
    }
    public ImageLoadConfig thumbnail(float size) {
        this.thumbnail = size;
        return this;
    }

    public ImageLoadConfig placehoder(@DrawableRes int placeholder) {
        this.placeholder=placeholder;
        return this;
    }

    public ImageLoadConfig errorRes(@DrawableRes int error) {
        this.errorholder=error;
        return this;
    }
    public ImageLoadConfig diskCache(@NonNull DiskCacheStrategy strategy) {
        this.diskCacheStrategy=strategy;
        return this;
    }
    public ImageLoadConfig skipCache(boolean isSkipCache){
        this.isSkipCache=isSkipCache;
        return this;
    }

    public ImageLoadConfig fileType(int type){
        this.fileType=type;
        return this;
    }
    public ImageLoadConfig format(DecodeFormat format){
        this.format=format;
        return this;
    }

    public ImageLoadConfig errorUrl(String fallbackUrl) {
        this.errorUrl=fallbackUrl;
        return this;
    }

    public ImageLoadConfig listener(IImageLoaderListener listener) {
        this.loaderListener=listener;
        return this;
    }


    public  static class FileType{
        public static final int Bitmap=1;
        public static final int Gif=2;
        public static final int Drawable=3;
        public static final int File=4;

    }
}
